const { DataTypes, Sequelize } = require("sequelize");
const sequelize = require("./sequelizeBaseConfig.js");

const UserInfo = sequelize.define(
  "UserInfo",
  {
    id: {
      type: DataTypes.BIGINT,
      comment: "ID",
      autoIncrement: true, //自增
      primaryKey: true, //主键
    },
    created_at: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "创建时间",
      defaultValue: new Date().toLocaleString(), //如果没有设置该字段的值则使用默认
    },
    updated_at: {
      type: DataTypes.DATE,
      allowNull: true,
      comment: "更新时间",
      defaultValue: new Date().toLocaleString(),
    },
    email: {
      type: DataTypes.STRING(30),
      comment: "邮箱",
      allowNullL: false,
    },
    nickname: {
      type: DataTypes.STRING(30),
      allowNull: true,
      comment: "昵称",
      defaultValue: "",
    },
    avatar: {
      type: DataTypes.STRING(1024),
      comment: "头像地址",
      defaultValue: "https://www.bing.com/rp/ar_9isCNU2Q-VG1yEDDHnx8HAFQ.png",
    },
    intro: {
      type: DataTypes.STRING(255),
      comment: "个人简介",
      defaultValue: "",
    },
    website: {
      type: DataTypes.STRING(255),
      comment: "个人网站",
      defaultValue: "https://www.hahacode.cn",
    },
    is_disable: {
      type: DataTypes.TINYINT(1),
      comment: "是否禁用(0-否 1-是)",
      defaultValue: 0,
    },
  },
  {
    tableName: "user_info",
    timestamps: false,
  }
);

module.exports = {
  UserInfo,
};
